package com.storeapp.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.storeapp.dao.ItemDao;
import com.storeapp.entity.domain.Item;

@Component
@Transactional
public class ItemService {
	@Autowired
	private ItemDao itemDao;
	
	@Transactional(readOnly = true)
	public Item getItem(Long id) {
		return itemDao.get(id);
	}

	public void saveOrUpdateItem(Item entity) {
		itemDao.save(entity);
	}
	
	public void deleteItem(Item entity) {
		itemDao.delete(entity);
	}

	public List<Item> listAll() {
		return itemDao.getAll();
	}
}
